package com.x.erp.dao;

import com.x.erp.thirdparty.ModelMappingThirdparty;
import com.x.framework.dao.BaseDao;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * 与第三方车型关系映射
 */
@Repository
public class ModelMappingThirdpartyDao extends BaseDao{
	
private final static String selectModelMappingThirdpartyListSql = "SELECT T1.* FROM ERP_MODEL_MAPPING_THIRDPARTY T1 WHERE 1=1 ";
	
	public List<ModelMappingThirdparty> selectModelMappingThirdpartyList(ModelMappingThirdparty modelMappingThirdparty) throws Exception{
		StringBuilder sb = new StringBuilder(selectModelMappingThirdpartyListSql);
		List<Object> params = new ArrayList<Object>();
		if(this.isNotNull(modelMappingThirdparty.getModelId())){
			sb.append("AND T1.MODEL_ID = ? ");
			params.add(modelMappingThirdparty.getModelId());
		}
		if(this.isNotNull(modelMappingThirdparty.getModelThirdpartyId())){
			sb.append("AND T1.MODEL_THIRDPARTY_ID = ? ");
			params.add(modelMappingThirdparty.getModelThirdpartyId());
		}
		if(this.isNotNull(modelMappingThirdparty.getModelType())){
			sb.append("AND T1.MODEL_TYPE = ? ");
			params.add(modelMappingThirdparty.getModelType());
		}
		return this.queryForList(sb.toString(), ModelMappingThirdparty.class, params);
	}

}
